<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改接入系统')" />
	<th:block th:include="include :: select2-css" />
</head>
<body>
    <div class="main-content">
        <form class="form-horizontal" id="form-bizsys-edit" th:object="${bizSys}">
            <input name="bizId"  type="hidden"  th:field="*{bizId}" />
            <h4 class="form-header h4">基本信息</h4>
            <div class="row">
            	<div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">接入系统名称：</label>
                        <div class="col-sm-8">
                            <input name="bizName" placeholder="请输入系统名称" class="form-control" type="text" maxlength="30" th:field="*{bizName}" required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">接入系统编号：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="bizCode" placeholder="请输入系统编号" class="form-control" type="text" maxlength="16" th:field="*{bizCode}" required>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">系统优先级：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="priority" placeholder="请输入优先级" class="form-control" type="text" maxlength="16" th:field="*{priority}"  required>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">接入系统地址：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input name="bizAddr" placeholder="请输入系统地址" class="form-control" type="text" th:field="*{bizAddr}"  required>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">接入系统状态：</label>
                        <div class="col-sm-8">
                            <label class="toggle-switch switch-solid">
	                            <input type="checkbox" id="status" th:checked="${bizSys.bizStatus == '0' ? true : false}">
	                            <span></span>
	                        </label>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: select2-js" />
	<script type="text/javascript">
        var prefix = ctx + "biz/sys";
        
        $("#form-bizsys-edit").validate({
        	onkeyup: false,
        	rules:{
        		email:{
                    email:true,
                    remote: {
                        url: prefix + "/checkEmailUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	"userId": function() {
                                return $("#userId").val();
                            },
                			"email": function() {
                                return $.common.trim($("#email").val());
                            }
                        }
                    }
        		},
        		phonenumber:{
        			isPhone:true,
                    remote: {
                        url: prefix + "/checkPhoneUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	"userId": function() {
                        		return $("#userId").val();
                            },
                			"phonenumber": function() {
                                return $.common.trim($("#phonenumber").val());
                            }
                        }
                    }
        		},
        	},
        	messages: {
        		"email": {
                    remote: "Email已经存在"
                },
        		"phonenumber":{
                	remote: "手机号码已经存在"
        		}
            },
            focusCleanup: true
        });
        
        function submitHandler() {
	        if ($.validate.form()) {
	        	var data = $("#form-bizsys-edit").serializeArray();
	        	var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
	        	data.push({"name": "bizStatus", "value": status});
	        	$.operate.saveTab(prefix + "/edit", data);
	        }
	    }

        /* 用户管理-修改-选择节点树 */
        function selectDeptTree() {
        	var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
            var url = ctx + "system/user/selectDeptTree/" + deptId;
		    var options = {
				title: '选择节点',
				width: "380",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doSubmit(index, layero){
			var body = $.modal.getChildFrame(index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			$.modal.close(index);
		}

    </script>
</body>
</html>